<?php
declare (strict_types = 1);

namespace app\admin\controller\wx;
use think\Request;
class Menu extends WxBase
{
    protected function initialize()
    {
        parent::initialize();
    }
    // 获取菜单设置
    public function getMenu() {
        // 读取（查询）已设置菜单
        $list = $this->app->menu->list();
        // 获取当前菜单
        $current = $this->app->menu->current();
        return json($current['selfmenu_info']);
    }
    // 创建或更新菜单
    public function updateMenu(){
        $data = $this->request->param();
        if(array_key_exists('button',$data))
        {   
            $this->app->menu->create($data['button']);
            return json('更新成功！');
        } else {
            return json('发生错误！',500);
        }
    }
    // 删除菜单
    public function deleteMenu($id){
        $this->app->menu->delete(); // 全部
        // $this->app->menu->delete($menuId);
    }
    // 测试菜单
    public function test(){
        $this->app->menu->match($userId);
    }
}
